<template>
	<view class="con_1">
		<view class="width_90">
			<view class="drawBox">
				<view class="top ft_14">可提现佣金</view>
				<view class="topMoney ft_32 fw-b">{{info.commission}}</view>
			</view>
			<view class="ft_18 fw-b" style="color: #33312E;">输入提数额</view>
			<!-- <view class="middle ft_12">100红包券=1现金</view> -->
			<!-- <view class="middle ft_12">100红包券=1现金</view> -->
			<view class="tiMoney ft_14">
				<input type="text" :disabled="isDisabled"   value="" v-model="money" @input="cc_money()"  placeholder="请输入提现数额"/>
			</view>
			<view>手续费：{{jf}}</view>
		</view>
		
		<!-- 银行卡信息 -->
		<view class="topName width_90">
			提现至
		</view>
		<view class="bankDetail">
			<view class="display just_space alipay ">
				<view class="ft_14 c-333">持卡人</view>
				<view class="">
					<u-input type="text" input-align="right" v-model="bankcard.username" placeholder="请输入持卡人姓名"/>
				</view>
			</view>
			<!-- <view class="display just_space alipay">
				<view class="ft_14 c-333">银行卡名称</view>
				<view class="">
					<u-input input-align="right" v-model="bankcard.bank_name" placeholder="请输入银行卡名称" maxlength="11"/>
				</view>
			</view> -->
			<view class="display just_space alipay">
				<view class="ft_14 c-333">开户行</view>
				<view class="">
					<u-input  input-align="right" v-model="bankcard.bank_address" placeholder="请输入开户行"/>
				</view>
			</view>
			<view class="display just_space alipay">
				<view class="ft_14 c-333">卡号</view>
				<view class="">
					<u-input  input-align="right" v-model="bankcard.bank_card" placeholder="请输入卡号"/>
				</view>
			</view>
		</view>
		<view class="btn" @tap="submit">确认提交</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isDisabled:false,
				info:{},
				money:'',
				bankcard:{
					username:'',
					bank_address:'',
					bank_name:'',
					bank_card:''
				},
				jf:0
			}
		},
		onLoad() {
			this.getBank()
			this.getInfo()
		},
		methods: {
			cc_money(e){
				// console.log(this.money);
				if(this.money*1>this.info.commission*1){
					this.money=this.info.commission;
				}
				// console.log(this.money,'999');
				var tx_jf=this.money*this.info.tx_jf_red;
				// console.log(tx_jf,'tx_jf');
				this.jf=tx_jf.toFixed(2);
			},
			getInfo(){
				this.$myRequest({
					url: 'api/user/index',
					method:'POST',
				}).then(res => {
					// console.log(res.data);
					if(res.data.code==1){
						let data=res.data.data
						this.info = data.info
						if(this.info.commission==0){
							this.isDisabled=true
						}
						else{
							this.isDisabled=false
						}
						//
					}
				})
			},
			getBank(){
				this.$myRequest({
					url: 'api/user/get_bank_info',
					method:'POST',
				}).then(res => {
					console.log(res.data);
					if(res.data.code==1){
						let data=res.data.data
						this.bankcard = data
					}
				})
			},
			submit(){
				if(this.bankcard.username==''){
					uni.showToast({
						icon:'none',
						title:'请填写持卡人'
					})
					return false;
				}
				if(this.bankcard.username==''){
					uni.showToast({
						icon:'none',
						title:'请填写卡号'
					})
					return false;
				}
				
				if(this.jf>this.info.score){
					uni.showToast({
						icon:'none',
						title:'您的大潜账号额度不足!'
					})
					return false;
				}
				if(this.money==''||this.money*1<=0){
					uni.showToast({
						icon:'none',
						title:'请填写提现额度'
					})
					return false;
				}
				
				
				this.$myRequest({
					url: 'api/user/withdrawal',
					method:'POST',
					data:{
						money:this.money,
						username:this.bankcard.username,
						// bank_name:this.bankcard.bank_name,
						bank_address:this.bankcard.bank_address,
						bank_card:this.bankcard.bank_card
					}
				}).then(res => {
					console.log(res.data);
					if(res.data.code==1){
						let data=res.data.data
						
						uni.navigateBack({
							data:1
						})
						// this.bankcard = data
					}
					uni.showToast({
						icon:'none',
						title:res.data.msg
					})
				})
			}
		}
	}
</script>

<style lang="scss">
page{background-color: #FAFAFA;}
// .con_1{
// 	width: 90%;margin: auto;
// }
.drawBox{
	margin: 40rpx 0;
	background-color: #fff;
	text-align: center;
	height: 270rpx;
	.top{
		padding-top: 60rpx;
		color: #666666;
		margin-bottom: 38rpx;
	}
}
.middle{
	margin: 18rpx 0;
	color: #333;
}
.tiMoney{
	height: 110rpx;
	line-height: 110rpx;
	text-align: center;
	background: #FFFFFF;
	border-radius: 16rpx;
	border: 2rpx solid #E6E6E6;
	color: #999;
}
.btn{
	width: 90%;
	margin:40rpx auto 0 auto;
	height: 100rpx;
	line-height: 100rpx;
	text-align: center;
	background: #FF9101;
	color: #FFFFFF;
	border-radius: 50rpx;
}
.topName{
	font-size: 18px;
	font-weight: bold;
	color: #33312E;
	margin: 40rpx auto 24rpx auto;
}
.bankDetail{
	background-color: #fff;
	.alipay{
		border-bottom: 1px solid #eeeeee;
		padding: 10px 0;
		width: 90%;margin:auto;
	}
}
.tiMoney{
	height: 110rpx;
	line-height: 110rpx;
	text-align: center;
	background: #FFFFFF;
	border-radius: 16rpx;
	border: 2rpx solid #E6E6E6;
	color: #999;
	input{
		height: 110rpx;
		line-height: 110rpx;
	}
}
</style>
